package com.pek.control.controller;


import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pek.control.entity.ProductEntity;
import com.pek.control.service.IConfigService;
import com.pek.control.service.IProductService;
import com.pek.util.RestResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

@RestController
@RequestMapping("/config")
public class ConfigController {
    @Autowired
    private IConfigService configService;

    @GetMapping("/getValue")
    public RestResult<String> getValue(@RequestParam String key){
        return RestResult.success(configService.getValue(key));
    }

    @PostMapping("/getValues")
    public RestResult<JSONObject> getValues(@RequestBody String[] keys){
        JSONObject result=new JSONObject();
        for (int i = 0; i < keys.length; i++) {
            String key=keys[i];
            result.put(key,configService.getValue(key));
        }
        return RestResult.success(result);
    }


}
